﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FSAPI
{
   public class InspectionDisp:InspectionDisp_
    {
        public delegate void voidSendCommand(List<bool> lb);
        public voidSendCommand SendCommandEvent = null;
        public override void SendCommand(List<bool> lb, Ice.Current current__)
        {
            if (SendCommandEvent != null)
                SendCommandEvent(lb);
            //throw new NotImplementedException();
        }

        public delegate void voidStart();
        public voidStart StartEvent = null;
        public override void Start(Ice.Current current__)
        {
            if (StartEvent != null)
            {
                StartEvent();
            }
            //throw new NotImplementedException();
        }
        public delegate void voidOpenApplication();
        public voidOpenApplication OpenApplicationEvent = null;
        public override void OpenApplication(Ice.Current current__)
        {
            if (OpenApplicationEvent != null)
            {
                OpenApplicationEvent();
            }
            //throw new NotImplementedException();
        }
        public delegate void voidChangeProduct(string pn);
        public voidChangeProduct ChangeProductEvent = null;

        public override void ChangeProduct(string pname,Ice.Current current__)
        {
            if (ChangeProductEvent != null)
            {
                ChangeProductEvent(pname);
            }
            //throw new NotImplementedException();
        }

        public delegate void voidCloseApplication();
        public voidCloseApplication CloseApplicationEvent = null;

        public override void CloseApplication(Ice.Current current__)
        {
            if (CloseApplicationEvent != null)
            {
                CloseApplicationEvent();
            }
            //throw new NotImplementedException();
        }

        public override void initiateCallback(InspectionCallBackPrx proxy, Ice.Current current__)
        {
            InspectionCallBack = proxy;
        }
        private InspectionCallBackPrx InspectionCallBack;
        public void ReturnResult(List<bool> lbResult)
        {
            if (InspectionCallBack != null)
            {
                InspectionCallBack.SendResult(lbResult);
            }
        }
        public bool ReturnBackMsg(string msg)
        {
            if (InspectionCallBack != null)
            {
                InspectionCallBack.BackMsg(msg);
                return true;
            }
            return false;
        }
        public void ReturnSendPicToHost(byte[] pic)
        {
            if (InspectionCallBack != null)
            {
                InspectionCallBack.SendPic(pic);
            }
        }
        public void ReturnSendInspResultToHost(ImageType ity)
        {
            if (InspectionCallBack != null)
            {
                InspectionCallBack.SendInfo (ity);
            }
        }
    }
}
